Skip to content

feat: add Black Duck API token detector#5063

Open
New1Direction wants to merge 1 commit into
trufflesecurity:mainfrom
New1Direction:feat/blackduck-detector
Open

feat: add Black Duck API token detector#5063
New1Direction wants to merge 1 commit into
trufflesecurity:mainfrom
New1Direction:feat/blackduck-detector

Conversation

@New1Direction

@New1Direction New1Direction commented Jun 22, 2026

Copy link
Copy Markdown

Adds a detector for Black Duck API tokens (the SCA tool). Closes #3012.

Black Duck tokens are base64 of uuid:uuid (100 chars ending in ==). Matching just the base64 shape is noisy, so the detector decodes the candidate and only keeps it when it's a colon-separated pair of UUIDs.

Black Duck is self-hosted, so verifying needs the server URL. I grab it from the surrounding context and POST to {server}/api/tokens/authenticate with Authorization: token <token>. 200 = valid, 401/403 = invalid, anything else is left indeterminate.

Tests: go test -tags=detectors ./pkg/detectors/blackduck/

A couple of notes:

  • I couldn't spin up a real Black Duck instance, so the verification path follows the documented token-auth API but hasn't been run against a live server.
  • A token with no server URL nearby isn't reported, since it can't be verified without the endpoint (same approach as the portainertoken detector). Happy to also flag token-only matches if you'd prefer.

Note

Medium Risk
Verification performs outbound HTTP to user-supplied Black Duck hosts with discovered tokens; behavior follows existing self-hosted detector patterns but live verification was not validated against a real server.

Overview
Adds a Black Duck secret scanner that finds base64 API tokens (decoded as uuid:uuid) near blackduck / black_duck keywords, pairs them with a co-located server URL, and registers DetectorType_BlackDuck (1053) in the default engine list.

Detection filters out raw base64 noise by requiring a valid UUID pair after decode. Findings are only emitted when a server URL is present in the same chunk (same pattern as Portainer token), with optional verification via POST {url}/api/tokens/authenticate and Authorization: token <token> (200 = verified, 401/403 = unverified).

Includes unit tests for token+URL matching, invalid token shape, token-only (no result), and BLACK_DUCK_* env-style prefixes.

Reviewed by Cursor Bugbot for commit 21c659f. Bugbot is set up for automated code reviews on this repo. Configure here.

@New1Direction New1Direction requested a review from a team June 22, 2026 21:53
@New1Direction New1Direction requested review from a team as code owners June 22, 2026 21:53
@CLAassistant

CLAassistant commented Jun 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 0ab5e6f. Configure here.

Comment thread pkg/detectors/blackduck/blackduck.go
Comment thread pkg/detectors/blackduck/blackduck.go Outdated
Black Duck API tokens are base64 of "uuid:uuid". The detector decodes the
candidate and only keeps it when it's a uuid pair, then verifies against the
self-hosted server's /api/tokens/authenticate endpoint.

Closes trufflesecurity#3012
@New1Direction New1Direction force-pushed the feat/blackduck-detector branch from 0ab5e6f to 21c659f Compare June 22, 2026 23:12
@New1Direction

Copy link
Copy Markdown
Author

Thanks for the review — both findings were valid and are fixed in 21c659f:

  • Keywords() missing black_duck: the regex accepts a black_duck prefix, but Keywords() only had blackduck, and black_duck isn't a substring of it — so the Aho-Corasick pre-filter would skip env-var style BLACK_DUCK_TOKEN=.... Added black_duck to the keyword set and a regression test that detects the underscore-only form against a host with no blackduck substring.
  • Swallowed request error in verifyToken: now returns the http.NewRequestWithContext error instead of nil, so an indeterminate failure surfaces via SetVerificationError like the other detectors.

go test -tags=detectors ./pkg/detectors/blackduck/ passes (4 cases).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detection of Blackduck API tokens as secret

2 participants